package in.muton.edushare.pages.publicpages.userpages;

import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.model.PropertyModel;

import com.edushare.common.util.StringUtil;
import com.edushare.common.vo.Publications;

import in.muton.edushare.pages.publicpages.userpages.ProfileTopMenu.MenuItems;

public class UserPublications extends UserProfileBase {

	public UserPublications(PageParameters params) {
		super(params);
		ListView<Publications> publist = 
			new ListView<Publications>("jitem", new PropertyModel<List<Publications>>(this, "pubs")){

				private static final long serialVersionUID = 1876399465605783721L;

				@Override
				protected void populateItem(ListItem<Publications> item) {
					item.add(new Label("jtitle", item.getModelObject().getTitle()));
					item.add(new Label("jauthor", item.getModelObject().getAuthors()));
					item.add(new Label("jjournal", item.getModelObject().getJournal()));
					if(StringUtil.isValid(item.getModelObject().getLinkToPaper()))
						item.add(new ExternalLink("jlink", item.getModelObject().getLinkToPaper()));
					else
						item.add(new EmptyPanel("jlink"));
					item.add(new Label("jabs", item.getModelObject().getAbstract()).setEscapeModelStrings(false));
				}
			
		};
		
		add(publist);
	}

	
	public List<Publications> getPubs(){
		return super.userModel.getObject().getPublications();
	}
	
	@Override
	public MenuItems getSelectedMenu() {
		return ProfileTopMenu.MenuItems.PUBLICATIONS;
	}

}
